/**   
* @Title: ClaimLaborMain.java 
* @Package com.infodms.dms.actions.claim.basicData 
* @Description: TODO(索赔工时维护Action) 
* @author Administrator   
* @date 2010-6-1 上午11:05:38 
* @version V1.0   
*/
package com.infodms.dms.actions.claim.basicData;

import java.util.Date;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

import com.infodms.dms.actions.common.ClaimCommonAction;
import com.infodms.dms.bean.AclUserBean;
import com.infodms.dms.common.Constant;
import com.infodms.dms.common.ErrorCodeConstant;
import com.infodms.dms.common.Utility;
import com.infodms.dms.common.getCompanyId.GetOemcompanyId;
import com.infodms.dms.dao.claim.basicData.ClaimLaborDao;
import com.infodms.dms.exception.BizException;
import com.infodms.dms.po.TtAsWrAdditionalitemPO;
import com.infodms.dms.po.TtAsWrTrobleMapPO;
import com.infodms.dms.po.TtAsWrWrlabinfoPO;
import com.infodms.dms.util.sequenceUitl.SequenceManager;
import com.infoservice.mvc.context.ActionContext;
import com.infoservice.mvc.context.RequestWrapper;
import com.infoservice.po3.bean.PageResult;

/** 
 * @ClassName: ClaimLaborMain 
 * @Description: TODO(索赔工时维护Action) 
 * @author Administrator 
 * @date 2010-6-1 上午11:05:38 
 *  
 */
public class ClaimLaborMain {
	private Logger logger = Logger.getLogger(ClaimLaborMain.class);
	private final ClaimLaborDao dao = ClaimLaborDao.getInstance();
	private final String CLAIM_LABOR_URL = "/jsp/claim/basicData/claimLaborIndex.jsp";//主页面（查询）
	private final String CLAIM_LABOR_ADD_URL = "/jsp/claim/basicData/claimLaborAdd.jsp";//新增页面
	private final String CLAIM_LABOR_UPDATE_URL = "/jsp/claim/basicData/claimLaborModify.jsp";//修改页面
	private final String ADDITIONAL_ADD_URL = "/jsp/claim/basicData/addLaborAdd.jsp";//附加工时新增页面
	private final String ADDITIONAL_UPDATE_URL = "/jsp/claim/basicData/addLaborModify.jsp";//附加工时修改页面
	private final String BUSINESS_ADD_URL = "/jsp/claim/basicData/troubleAdd.jsp";//故障代码新增页面
	private final String CLAIM_LABOR_DETAIL_URL = "/jsp/claim/basicData/claimLaborCodeDetail.jsp";//详细信息页面
	private final ClaimCommonAction claimCommon = ClaimCommonAction.getInstance();
	/**
	 * 
	* @Title: claimLaborInit 
	* @Description: TODO(索赔工时维护初始化) 
	* @param    
	* @return void  
	* @throws
	 */
	public void claimLaborInit(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		String flag = "0";
		try {
			RequestWrapper request = act.getRequest();
			Long oemCompanyId = GetOemcompanyId.getOemCompanyId(logonUser);
			//modify at 2010-07-23 增加是否是新增或修改返回的标识，flag=1：是，flag= 0：否
			flag = request.getParamValue("reFlag");//
			act.setOutData("REFLAG", flag);
			//modify at 2010-07-23 end
			act.setOutData("wrmodelgrouplist",claimCommon.getWrModelGroupList("1",Constant.WR_MODEL_GROUP_TYPE_01,oemCompanyId));
			act.setForword(CLAIM_LABOR_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时维护");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: getWrModelGroupList 
	* @Description: TODO(获取索赔工时车型组列表) 
	* @param @return   
	* @return String  
	* @throws
	 */
	public String getWrModelGroupList(String type){
		List list = dao.getClaimWrModelGroup(Constant.WR_MODEL_GROUP_TYPE_01);
		String retStr="";
		if("1".equals(type)){
			retStr+="<option value=\'\'>-请选择-</option>";
		}
		if(list != null && list.size() > 0){
			for(int i=0;i<list.size();i++){
				HashMap map = new HashMap();
				map=(HashMap)list.get(i);
				retStr+="<option value=\'"+map.get("WRGROUP_ID")+"\'>"+map.get("WRGROUP_CODE")+"</option>";
			}
		}
		return retStr;
	}
	/**
	 * 
	* @Title: claimLaborQuery 
	* @Description: TODO(索赔工时查询) 
	* @param    
	* @return void  
	* @throws
	 */
	public void claimLaborQuery() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		Long oemCompanyId=GetOemcompanyId.getOemCompanyId(logonUser);    
		List<Object> params = new LinkedList<Object>();
		StringBuffer sb = new StringBuffer();
		try {
			RequestWrapper request = act.getRequest();
			act.getResponse().setContentType("application/json");
			if("1".equals(request.getParamValue("COMMAND"))){ //开始查询
				//代码列别
				String wrgroupId = request.getParamValue("WRGROUP_ID");//车型组
				String labourCode = request.getParamValue("LABOUR_CODE");//工时代码
				String cnDes = request.getParamValue("CN_DES");//中文说明(工时名称)
				//modify at 2010-07-20 start
				String labourCodebig = request.getParamValue("LABOUR_CODE_BIG");//工时大类代码
				String cnDesbig = request.getParamValue("CN_DES_BIG");//工时大类名称	
				//modify at 2010-07-20 end
				//拼sql的查询条件
				if (Utility.testString(wrgroupId)) {
					sb.append(" and taww.wrgroup_id = ? ");
					params.add(wrgroupId);
				}
				//modify 工时代码不区分大小写
				if (Utility.testString(labourCode)) {
					sb.append(" and upper(taww.labour_code) like ? ");
					params.add("%"+labourCode.toUpperCase()+"%");
				}
				if (Utility.testString(cnDes)) {
					sb.append(" and taww.cn_des like ? ");
					params.add("%"+cnDes+"%");
				}
				//modify at 2010-07-20 start
				//增加工时大类代码、名称查询条件
				if(Utility.testString(labourCodebig) || Utility.testString(cnDesbig)){
					sb.append(" and taww.pater_id in (select t2.id\n" );
					sb.append(" from tt_as_wr_wrlabinfo t2\n" );
					sb.append(" where 1=1\n" );
					if(Utility.testString(labourCodebig)){
						sb.append(" and upper(t2.labour_code) like ? \n" );
						params.add("%"+labourCodebig.toUpperCase()+"%");
					}
					if(Utility.testString(cnDesbig)){
						sb.append(" and t2.cn_des like ? \n" );
						params.add("%"+cnDesbig+"%");
					}
					sb.append(" and t2.tree_code in (1, 2))\n");
				}
//				modify at 2010-07-20 end
				Integer curPage = request.getParamValue("curPage") != null ? Integer
						.parseInt(request.getParamValue("curPage"))
						: 1; // 处理当前页
				
				PageResult<Map<String, Object>> ps = dao.claimLaborQuery(Constant.PAGE_SIZE, curPage,oemCompanyId,sb.toString(),params);
				act.setOutData("ps", ps);
			}
		} catch(BizException e){
			logger.error(logonUser,e);
			act.setException(e);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: claimLaborAddInit 
	* @Description: TODO(索赔工时新增初始化) 
	* @param    
	* @return void  
	* @throws
	 */
	public void claimLaborAddInit(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			Long oemCompanyId = GetOemcompanyId.getOemCompanyId(logonUser);
			act.setOutData("wrmodelgrouplist",claimCommon.getWrModelGroupList("0",Constant.WR_MODEL_GROUP_TYPE_01,oemCompanyId));
			act.setForword(CLAIM_LABOR_ADD_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: claimLaborAdd 
	* @Description: TODO(索赔工时新增:旧的方法) 
	* @param    
	* @return void  
	* @throws
	 */
	@SuppressWarnings("unchecked")
	public void claimLaborAddOLD(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String errorMsg = null;
			Long oemCompanyId = GetOemcompanyId.getOemCompanyId(logonUser);
			String laborCode = request.getParamValue("LABOR_CODE");  //索赔工时代码
			String laborName = request.getParamValue("LABOR_NAME");  //索赔工时名称
			String wrgroupId = request.getParamValue("WRGROUP_ID");  //索赔车型组ID
			String firstClass = request.getParamValue("FIRST_CLASS");//大类
			String secondClass = request.getParamValue("SECOND_CLASS");//小类
			float labourQuotiety = Utility.getFloat(request.getParamValue("LABOR_QUOTIETY")) ;//工时系数
			float labourHour = Utility.getFloat(request.getParamValue("LABOUR_HOUR"));//索赔工时
			String firstLetter = String.valueOf(laborCode.charAt(0));//大类代码
			String firstTwoLetter = laborCode.substring(0,2);//小类代码
			//待增加的po
			TtAsWrWrlabinfoPO addpo = new TtAsWrWrlabinfoPO();
			addpo.setWrgroupId(new Long(wrgroupId));
			addpo.setCreateBy(logonUser.getUserId());
			addpo.setCreateDate(new Date());
			
			//判断大类是否存在：
			TtAsWrWrlabinfoPO firstpo = new TtAsWrWrlabinfoPO();
			firstpo.setWrgroupId(new Long(wrgroupId));
			firstpo.setLabourCode(firstLetter);
			firstpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_01);//大类树
			List list = dao.select(firstpo);
			if(list != null && list.size() == 0){
				if(Utility.testString(firstClass)){
					addpo.setCnDes(firstClass);
					addpo.setLabourCode(firstLetter);
					addpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_01);
					addpo.setLabourHour(Float.parseFloat("0"));
					addpo.setLabourQuotiety(Float.parseFloat("0"));
					addpo.setId(Long.parseLong(SequenceManager.getSequence("")));
					dao.insert(addpo);
				}else{
					errorMsg = "F";//大类名称没有
				}
			}
			if(errorMsg == null){
				TtAsWrWrlabinfoPO secondpo = new TtAsWrWrlabinfoPO();
				secondpo.setWrgroupId(new Long(wrgroupId));
				secondpo.setLabourCode(firstTwoLetter);
				secondpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_02);//小类树
				List seclist = dao.select(secondpo);
				if(seclist != null && seclist.size() == 0){
					if(Utility.testString(secondClass)){
						addpo.setCnDes(secondClass);
						addpo.setLabourCode(firstTwoLetter);
						addpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_02);
						addpo.setLabourHour(Float.parseFloat("0"));
						addpo.setLabourQuotiety(Float.parseFloat("0"));
						addpo.setId(Long.parseLong(SequenceManager.getSequence("")));
						dao.insert(addpo);
					}else{
						errorMsg = "S";//小类名称没有
					}
				}				
				
			}
			if(errorMsg == null){
				TtAsWrWrlabinfoPO selpo = new TtAsWrWrlabinfoPO();
				selpo.setWrgroupId(new Long(wrgroupId));
				selpo.setLabourCode(laborCode);
//				selpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_03);//小类树
				List sellist = dao.select(selpo);
				if(sellist != null && sellist.size() == 0){
					addpo.setCnDes(laborName);
					addpo.setLabourCode(laborCode);
					addpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_03);
					addpo.setLabourHour(labourHour);
					addpo.setLabourQuotiety(labourQuotiety);
					addpo.setId(Long.parseLong(SequenceManager.getSequence("")));
					dao.insert(addpo);
				}else{
					errorMsg = laborCode;//工时代码已经存在
				}
			}

			act.setOutData("wrmodelgrouplist",claimCommon.getWrModelGroupList("0",Constant.WR_MODEL_GROUP_TYPE_01,oemCompanyId));
			act.setOutData("error", errorMsg);
			act.setOutData("success", "true");
			
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: claimLaborAdd 
	* @Description: TODO(索赔工时新增) 
	* @param    
	* @return void  
	* @throws
	* modify at 2010-07-15
	 */
	@SuppressWarnings("unchecked")
	public void claimLaborAdd(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String errorMsg = null;
			String laborCode = request.getParamValue("LABOR_CODE");  //索赔工时代码
			String laborName = request.getParamValue("LABOR_NAME");  //索赔工时名称
			String wrgroupId = request.getParamValue("WRGROUP_ID");  //索赔车型组ID
			String paterId = request.getParamValue("P_ID");//工时大类
			float labourQuotiety = Utility.getFloat(request.getParamValue("LABOR_QUOTIETY")) ;//工时系数
			float labourHour = Utility.getFloat(request.getParamValue("LABOUR_HOUR"));//索赔工时
			
			Long oemCompanyId = GetOemcompanyId.getOemCompanyId(logonUser);
			//待增加的po
			TtAsWrWrlabinfoPO addpo = new TtAsWrWrlabinfoPO();
			addpo.setWrgroupId(new Long(wrgroupId));
			addpo.setCreateBy(logonUser.getUserId());
			addpo.setCreateDate(new Date());
			if(errorMsg == null){
				TtAsWrWrlabinfoPO selpo = new TtAsWrWrlabinfoPO();
				selpo.setWrgroupId(new Long(wrgroupId));
				selpo.setLabourCode(laborCode);
				List sellist = dao.select(selpo);
				if(sellist != null && sellist.size() == 0){
					addpo.setCnDes(laborName);
					addpo.setLabourCode(laborCode);
					addpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_03);
					addpo.setLabourHour(labourHour);
					addpo.setLabourQuotiety(labourQuotiety);
					addpo.setPaterId(Utility.getLong(paterId));//大类
					addpo.setId(Long.parseLong(SequenceManager.getSequence("")));
					addpo.setOemCompanyId(oemCompanyId);
					dao.insert(addpo);
				}else{
					errorMsg = laborCode;//工时代码已经存在
				}
			}

			act.setOutData("wrmodelgrouplist",claimCommon.getWrModelGroupList("0",Constant.WR_MODEL_GROUP_TYPE_01,oemCompanyId));
			act.setOutData("error", errorMsg);
			act.setOutData("success", "true");
			
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}	
	/**
	 * 
	* @Title: AdditionalLaborAddInit 
	* @Description: TODO(附加工时新增初始化) 
	* @param    
	* @return void  
	* @throws
	 */
	public void additionalLaborAddInit(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String wId = request.getParamValue("ID");//工时id
			String wrgroupId = request.getParamValue("WRGROUP_ID");//车型组
			act.setOutData("W_ID", wId);
			act.setOutData("WRGROUP_ID", wrgroupId);
			act.setForword(ADDITIONAL_ADD_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: AdditionalLaborAdd 
	* @Description: TODO(附加工时新增) 
	* @param    
	* @return void  
	* @throws
	 */
	@SuppressWarnings("unchecked")
	public void additionalLaborAdd(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		Long oemCompanyId=GetOemcompanyId.getOemCompanyId(logonUser); 
		String errorMsg = null;
		try {
			RequestWrapper request = act.getRequest();
			String wId = request.getParamValue("W_ID");//工时id
			String wrgroupId = request.getParamValue("WRGROUP_ID");//车型组
			String labourCode = request.getParamValue("ADD_LABOUR_CODE");//附加工时代码
			String cnDes = request.getParamValue("ADD_CN_DES");//附加工时名称
			float labourQuotiety = Utility.getFloat(request.getParamValue("ADD_LABOUR_QUOTIETY"));//工时系数
			float labourHour = Utility.getFloat(request.getParamValue("ADD_LABOUR_HOUR"));//索赔工时
				TtAsWrWrlabinfoPO selpo = new TtAsWrWrlabinfoPO();
				selpo.setWrgroupId(new Long(wrgroupId));
				selpo.setLabourCode(labourCode);
				List sellist = dao.select(selpo);
				if(sellist != null && sellist.size() == 0){
					//索赔工时表增加一条记录：
					TtAsWrWrlabinfoPO addpo = new TtAsWrWrlabinfoPO();
					addpo.setId(Long.parseLong(SequenceManager.getSequence("")));
					addpo.setCreateBy(logonUser.getUserId());
					addpo.setCreateDate(new Date());
					addpo.setTreeCode(Constant.CLAIM_LABHOUR_TREE_CODE_04);//附加工时层：4
					addpo.setCnDes(cnDes);
					addpo.setLabourCode(labourCode);
					addpo.setLabourHour(labourHour);
					addpo.setLabourQuotiety(labourQuotiety);
					addpo.setWrgroupId(new Long(wrgroupId));
					addpo.setOemCompanyId(oemCompanyId);
					dao.insert(addpo);
					//索赔工时附加工时关系表增加一条记录：
					TtAsWrAdditionalitemPO additempo = new TtAsWrAdditionalitemPO();
					additempo.setId(Long.parseLong(SequenceManager.getSequence("")));
					additempo.setAddId(addpo.getId());//附加工时id
					additempo.setWId(new Long(wId));//索赔工时id
					additempo.setCreateBy(logonUser.getUserId());
					additempo.setCreateDate(new Date());
					dao.insert(additempo);
					additionalLaborReturn(wId);
				}else{
					errorMsg = labourCode;//工时代码已经存在
				}
				act.setOutData("error", errorMsg);
				act.setOutData("success", "true");
			
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: additionalLaborUpdateInit 
	* @Description: TODO(附加工时修改初始化) 
	* @param    
	* @return void  
	* @throws
	 */
	public void additionalLaborUpdateInit(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String id=request.getParamValue("ID");
			String wId = request.getParamValue("W_ID");//索赔工时id
			HashMap hm = null;
			hm = dao.getAdddClaimLaborById(new Long(id));
			
			act.setOutData("SELMAP", hm);//对应的索赔工时
			act.setOutData("WID", wId);
			act.setForword(ADDITIONAL_UPDATE_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: additionalLaborUpdate 
	* @Description: TODO(附加工时修改) 
	* @param    
	* @return void  
	* @throws
	 */
	public void additionalLaborUpdate(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		TtAsWrWrlabinfoPO selpo = null;
		TtAsWrWrlabinfoPO updatepo = null;
		try {
			RequestWrapper request = act.getRequest();
			String id=request.getParamValue("ID");
			String wId = request.getParamValue("W_ID");//工时id
			float labourQuotiety = Utility.getFloat(request.getParamValue("ADD_LABOUR_QUOTIETY"));//工时系数
			float labourHour = Utility.getFloat(request.getParamValue("ADD_LABOUR_HOUR"));//索赔工时
			selpo = new TtAsWrWrlabinfoPO();
			selpo.setId(new Long(id));
			updatepo = new TtAsWrWrlabinfoPO();
			updatepo.setLabourQuotiety(labourQuotiety);
			updatepo.setLabourHour(labourHour);
			updatepo.setUpdateBy(logonUser.getUserId());
			updatepo.setUpdateDate(new Date());
			dao.laborUpdate(selpo, updatepo);
			additionalLaborReturn(wId);

		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	
	/**
	 * 
	* @Title: additionalLaborReturn 
	* @Description: TODO(附加工时新增回显) 
	* @param @param id   
	* @return void  
	* @throws
	 */
	private void additionalLaborReturn(String id){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			HashMap hm = null;
			hm = dao.getClaimLaborById(new Long(id));
			List addlist =  dao.getAddLabourById(new Long(id));
			List businessCodeList = dao.getBussCodeById(new Long(id));
			act.setOutData("SELMAP", hm);//对应的索赔工时
			act.setOutData("ADDLIST", addlist);//索赔工时对应的附加工时			
			act.setOutData("BUSCODELIST", businessCodeList);//索赔工时对应的故障代码
			act.setForword(CLAIM_LABOR_UPDATE_URL);			
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
	}
	/**
	 * 
	* @Title: additionalLaborDel 
	* @Description: TODO(附加工时删除) 
	* @param    
	* @return void  
	* @throws
	 */
	@SuppressWarnings("unchecked")
	public void additionalLaborDel(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		TtAsWrWrlabinfoPO selpo = null;
		TtAsWrWrlabinfoPO updatepo = null;
//		TtAsWrAdditionalitemPO addSelpo = null;
//		TtAsWrAdditionalitemPO addUpdatepo = null;
		TtAsWrAdditionalitemPO delpo = null;
		try {
			RequestWrapper request = act.getRequest();
			String id = request.getParamValue("ID");  //关系表ID
			String addId = request.getParamValue("ADD_ID");//附加工时ID
//			String wId = request.getParamValue("W_ID");//索赔工时ID
			selpo = new TtAsWrWrlabinfoPO();
			selpo.setId(new Long(addId));
			updatepo = new TtAsWrWrlabinfoPO();
			updatepo.setIsDel(Constant.IS_DEL);//删除标记
			updatepo.setUpdateBy(logonUser.getUserId());
			updatepo.setUpdateDate(new Date());
			dao.laborUpdate(selpo, updatepo);//删除索赔工时表
			
//			addSelpo = new TtAsWrAdditionalitemPO();
//			addUpdatepo = new TtAsWrAdditionalitemPO();
//			addSelpo.setAddId(new Long(id));
//			addSelpo.setWId(new Long(wId));
//			addUpdatepo.setIsDel(Constant.IS_DEL);//删除标记
//			addUpdatepo.setUpdateBy(logonUser.getUserId());
//			addUpdatepo.setUpdateDate(new Date());
//			dao.laborUpdate(addSelpo, addUpdatepo);//删除索赔工时附加工时关系表
			delpo = new TtAsWrAdditionalitemPO();
			delpo.setId(new Long(id));
			dao.delete(delpo);
			act.setOutData("success", "true");

		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: businessCodeDel 
	* @Description: TODO(故障代码关联删除) 
	* @param    
	* @return void  
	* @throws
	 */
	@SuppressWarnings("unchecked")
	public void businessCodeDel(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		TtAsWrTrobleMapPO delpo = null;
		try {
			RequestWrapper request = act.getRequest();
			String id = request.getParamValue("ID");  //索赔工时与故障代码对应ID
			delpo = new TtAsWrTrobleMapPO();
			delpo.setMapId(new Long(id));
			dao.delete(delpo);
			act.setOutData("success", "true");
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}	
	/**
	 * 
	* @Title: claimLaborUpdateInit 
	* @Description: TODO(索赔工时修改初始化) 
	* @param    
	* @return void  
	* @throws
	 */
	public void claimLaborUpdateInit(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String id=request.getParamValue("ID");
			HashMap hm = null;
			hm = dao.getClaimLaborById(new Long(id));
			List addlist =  dao.getAddLabourById(new Long(id));
			List businessCodeList = dao.getBussCodeById(new Long(id));
			
			act.setOutData("SELMAP", hm);//对应的索赔工时
			act.setOutData("ADDLIST", addlist);//索赔工时对应的附加工时
			act.setOutData("BUSCODELIST", businessCodeList);//索赔工时对应的故障代码
			act.setForword(CLAIM_LABOR_UPDATE_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: claimLaborUpdate 
	* @Description: TODO(索赔工时修改) 
	* @param    
	* @return void  
	* @throws
	 */
	public void claimLaborUpdate(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		TtAsWrWrlabinfoPO selpo = null;
		TtAsWrWrlabinfoPO updatepo = null;
		try {
			RequestWrapper request = act.getRequest();
			String id=request.getParamValue("ID");
			String wrgroupId=request.getParamValue("WRGROUP_ID");
			float labourQuotiety = Utility.getFloat(request.getParamValue("LABOUR_QUOTIETY"));//工时系数
			float labourHour = Utility.getFloat(request.getParamValue("LABOUR_HOUR"));//索赔工时
			//modify at 2010-07-28 start
			//增加索赔工时大类
			//String pLabourCode=request.getParamValue("P_LABOUR_CODE");//工时大类代码
			String pId=request.getParamValue("P_ID");//工时大类ID
			//modify at 2010-07-28 end
			selpo = new TtAsWrWrlabinfoPO();
			selpo.setId(new Long(id));
			selpo.setWrgroupId(new Long(wrgroupId));
			updatepo = new TtAsWrWrlabinfoPO();
			updatepo.setLabourQuotiety(labourQuotiety);
			updatepo.setLabourHour(labourHour);
			updatepo.setPaterId(Utility.getLong(pId));
			updatepo.setIfStatus(0);
			updatepo.setUpdateBy(logonUser.getUserId());
			updatepo.setUpdateDate(new Date());
			dao.claimlaborUpdate(selpo, updatepo);
			act.setOutData("success", "true");

		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: businessCodeAddInit 
	* @Description: TODO(故障代码新增初始化) 
	* @param    
	* @return void  
	* @throws
	 */
	public void businessCodeAddInit(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		Long companyId=GetOemcompanyId.getOemCompanyId(logonUser);
		try {
			RequestWrapper request = act.getRequest();
			String laborId = request.getParamValue("ID");//索赔工时ID
			List busicodelist = dao.getBusinessCodeByType(Constant.BUSINESS_CHNG_CODE_04,laborId,companyId);
			act.setOutData("BUSICODELIST", busicodelist);
			act.setOutData("W_ID", laborId);
			act.setForword(BUSINESS_ADD_URL);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: businessCodeAdd 
	* @Description: TODO(故障代码新增) 
	* @param    
	* @return void  
	* @throws
	 */
	@SuppressWarnings("unchecked")
	public void businessCodeAdd(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String laborId = request.getParamValue("W_ID");//索赔工时ID
			String[] troubleIdArray = request.getParamValues("businesscodeIds");//要添加的故障代码id
//			String troubleIds = request.getParamValue("businesscodeIds");//要添加的故障代码id，以,隔开
				for (int i = 0;i<troubleIdArray.length;i++) {
					TtAsWrTrobleMapPO tawtmpo = new TtAsWrTrobleMapPO();
					tawtmpo.setMapId(Long.parseLong(SequenceManager.getSequence("")));//id
					tawtmpo.setLaborId(new Long(laborId));
					tawtmpo.setTroubleId(new Long(troubleIdArray[i]));
					dao.insert(tawtmpo);
				}
			additionalLaborReturn(laborId);
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}		
		
	}
	/**
	 * 
	* @Title: claimLaborDel 
	* @Description: TODO(索赔工时删除) 
	* @param    
	* @return void  
	* @throws
	 */
	public void claimLaborDel(){
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		TtAsWrWrlabinfoPO delpo = null;
		TtAsWrWrlabinfoPO selpo = null;
		try {
			RequestWrapper request = act.getRequest();
			String id = request.getParamValue("ID");  //索赔工时ID
			selpo = new TtAsWrWrlabinfoPO();
			selpo.setId(new Long(id));
			delpo = new TtAsWrWrlabinfoPO();
			delpo.setIsDel(Constant.IS_DEL);
			delpo.setUpdateBy(logonUser.getUserId());
			delpo.setUpdateDate(new Date());
			dao.deleteClaimlabor(new Long(id), selpo, delpo);
			act.setOutData("success", "true");
		} catch (Exception e) {
			BizException e1 = new BizException(act,e,ErrorCodeConstant.QUERY_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}
	}
	/**
	 * 
	* @Title: claimLaborDetail 
	* @Description: TODO(索赔工时详细信息) 
	* @param    
	* @return void  
	* @throws
	 */
	public void claimLaborDetail() {
		ActionContext act = ActionContext.getContext();
		AclUserBean logonUser = (AclUserBean)act.getSession().get(Constant.LOGON_USER);
		try {
			RequestWrapper request = act.getRequest();
			String id=request.getParamValue("ID");
			HashMap hm = null;
			hm = dao.getClaimLaborById(new Long(id));
			List addlist =  dao.getAddLabourById(new Long(id));
			List businessCodeList = dao.getBussCodeById(new Long(id));
			
			act.setOutData("SELMAP", hm);//对应的索赔工时
			act.setOutData("ADDLIST", addlist);//索赔工时对应的附加工时
			act.setOutData("BUSCODELIST", businessCodeList);//索赔工时对应的故障代码
			act.setForword(CLAIM_LABOR_DETAIL_URL);
		} catch(Exception e){
			BizException e1 = new BizException(act,e,ErrorCodeConstant.DETAIL_FAILURE_CODE,"索赔工时");
			logger.error(logonUser,e1);
			act.setException(e1);
		}

	}

}
